package com.hitechbangla.fctu.base.base;

import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import resource_builder.GenericTypeBuilder;

/**
 *
 * @author deb kanti
 */
public class BaseType implements Serializable
{
    private String name;
    private float takeOfHeading;
    
    private static final long serialVersionUID = 3L;

    public BaseType(String name, float takeOfHeading)
    {
        this.name = name;
        this.takeOfHeading = takeOfHeading;
    }
            
    /**
     * @return the name
     * 
     * 
     */
    public String getName() 
    {
        return name;
    }

    /**
     * @param name the name to set
     */
    public void setName(String name) 
    {
        this.name = name;
    }

    /**
     * @return the takeOfHeading
     */
    public float getTakeOfHeading() 
    {
        return takeOfHeading;
    }

    /**
     * @param takeOfHeading the takeOfHeading to set
     */
    public void setTakeOfHeading(float takeOfHeading) 
    {
        this.takeOfHeading = takeOfHeading;
    }
    
    public static List<BaseType> getAllBaseTypes()
    {
        GenericTypeBuilder<BaseType> genericTypeBuilder = new GenericTypeBuilder<>();
        List<BaseType> listBaseType = genericTypeBuilder.readAll("baseType.object");
        if(listBaseType!=null)
        {
            return listBaseType;
        }
        else
        {
            return new ArrayList<BaseType>();
        }
	
        
	/*
        String[] strBaseType = new String[listBaseType.size()];
        
        for(int i=0;i<strBaseType.length;i++)
        {
            strBaseType[i] = listBaseType.get(i).getName();
        }
        return strBaseType;
	*/
    }
    public static void updateBase(List<BaseType> listBaseType)
    {
	try
	{
	    FileOutputStream fileOutputStream = new FileOutputStream("src/resources/baseType.object");
	    ObjectOutputStream  objectOutputStream = new ObjectOutputStream(fileOutputStream);

	    objectOutputStream.writeObject(listBaseType);
	    objectOutputStream.close();
	}
	catch(Exception ex)
	{
	    
	}
    }
    
}
